
<?php

	class UpdateManager{
	
		public function validate($snum,$fnme,$lnme,$mnme,$bday,$gendr,$cstatus,$lschool,$lschtype,$religion,$class,$stfap,$schol,$stipe,$cp,$email,$hobbies,$honors,$talents,$ailments,$meds,$addres,$fdnme,$fjob,$faddress,$fincome,$flife,$femployer,$fcp,$mdnme,$mjob,$maddress,$mincome,$mlife,$memployer,$mcp,$regn,$stats,$numbro,$numsis,$order,$gnme,$gadd,$gnum,$course,$college){
		
				if(is_numeric($snum)&&is_numeric($stipe)&&is_numeric($cp)&&($fname!=""||$fname!=null)&&($lname!=""||$lname!=null)&&($bday!=""||$bday!=null)
				&&($gendr!=""||$gendr!=null)&&($cstatus!=""||$cstatus!=null)&&($lschool!=""||$lschool!=null)&&($lschtype!=""||$lschtype!=null)&&($religion!=""||$religion!=null)
				&&($class!=""||$class!=null)&&($stfap!=""||$stfap!=null)&&($cp!=""||$cp!=null)&&($email!=""||$email!=null)&&($gname!=""||$gname!=null)&&($gadd!=""||$gadd!=null)&&($course!=""||$course!=null)&&is_numeric($gnum)){
						return true;
					}else{
						return false;
				}
		}
	
		function updateResident($snum,$lname,$fname,$mname,$gender,$status,$bday,$course,$religion,$address,$lschool,$type,$class,$stfap,$schol,$stipe,$cp,$email,$hobbies,$honors,$talents,$ailments,$meds,$fathername,$fjob,$foffice,$fincome,$flife,$femployer,$ftelnum,$mothername,$mjob,$moffice,$mincome,$mlife,$memployer,$mtelnum,$region,$parentStatus,$numbro,$numsis,$order,$gname,$gadd,$gnum,$college){
			$flag=1;
			$conn = oci_connect("naiad", "1234", "localhost/XE");
			
			$s = oci_parse($conn, "UPDATE student SET namefirst ='".$fname."' WHERE studentno = '".$snum."'" );
			$check[0] = oci_execute($s);
			
			$s1 = oci_parse($conn, "UPDATE student SET namelast ='".$lname."' WHERE studentno = '".$snum."'" );
			$check[1] = oci_execute($s1);
			
			$s2 = oci_parse($conn, "UPDATE student SET namemiddle ='".$mname."' WHERE studentno = '".$snum."'" );
			$check[2] = oci_execute($s2);
			
			$s3 = oci_parse($conn, "UPDATE student SET gender ='".$gender."' WHERE studentno = '".$snum."'" );
			$check[3] = oci_execute($s3);
			
			$s4 = oci_parse($conn, "UPDATE student SET civilstatus ='".$status."' WHERE studentno = '".$snum."'" );
			$check[4] = oci_execute($s4);
			
			$s5 = oci_parse($conn, "UPDATE student SET birthdate ='".$bday."' WHERE studentno = '".$snum."'" );
			$check[5] = oci_execute($s5);
			
			$s6 = oci_parse($conn, "UPDATE student SET course ='".$course."' WHERE studentno = '".$snum."'" );
			$check[6] = oci_execute($s6);
			
			$s7 = oci_parse($conn, "UPDATE student SET religion ='".$religion."' WHERE studentno = '".$snum."'" );
			$check[7] = oci_execute($s7);
			
			$s8 = oci_parse($conn, "UPDATE student SET homeaddress='".$address."' WHERE studentno = '".$snum."'" );
			$check[8] = oci_execute($s8);
			
			$s9 = oci_parse($conn, "UPDATE student SET lastschool ='".$lschool."' WHERE studentno = '".$snum."'" );
			$check[9] = oci_execute($s9);
			
			$s10 = oci_parse($conn, "UPDATE student SET lastschooltype ='".$type."' WHERE studentno = '".$snum."'" );
			$check[10] = oci_execute($s10);
			
			$s11 = oci_parse($conn, "UPDATE student SET classification ='".$class."' WHERE studentno = '".$snum."'" );
			$check[11] = oci_execute($s11);
			
			$s12 = oci_parse($conn, "UPDATE student SET stfapbracket ='".$stfap."' WHERE studentno = '".$snum."'" );
			$check[12] = oci_execute($s12);
			
			$s13 = oci_parse($conn, "UPDATE student SET scholarships ='".$schol."' WHERE studentno = '".$snum."'" );
			$check[13] = oci_execute($s13);
			
			$s14 = oci_parse($conn, "UPDATE student SET allowance ='".$stipe."' WHERE studentno = '".$snum."'" );
			$check[14] = oci_execute($s14);
			
			$s15 = oci_parse($conn, "UPDATE student SET email ='".$email."' WHERE studentno = '".$snum."'" );
			$check[15] = oci_execute($s15);
			
			$s16 = oci_parse($conn, "UPDATE student SET cellno ='".$cp."' WHERE studentno = '".$snum."'" );
			$check[16] = oci_execute($s16);
			
			$s17 = oci_parse($conn, "UPDATE student SET hobbies ='".$hobbies."' WHERE studentno = '".$snum."'" );
			$check[17] = oci_execute($s17);
			
			$s18 = oci_parse($conn, "UPDATE student SET honors ='".$honors."' WHERE studentno = '".$snum."'" );
			$check[18] = oci_execute($s18);
			
			$s19 = oci_parse($conn, "UPDATE student SET talents ='".$talents."' WHERE studentno = '".$snum."'" );
			$check[19] = oci_execute($s19);
			
			$s20 = oci_parse($conn, "UPDATE student SET ailments ='".$ailments."' WHERE studentno = '".$snum."'" );
			$check[20] = oci_execute($s20);
			
			$s21 = oci_parse($conn, "UPDATE student SET medications ='".$meds."' WHERE studentno = '".$snum."'" );
			$check[21] = oci_execute($s21);
			
			
			$p =  oci_parse($conn, "UPDATE parents SET fathername ='".$fathername."' WHERE studentno = '".$snum."'" );
			$check[22] = oci_execute($p);
			
			$p1 =  oci_parse($conn, "UPDATE parents SET fjob ='".$fjob."' WHERE studentno = '".$snum."'" );
			$check[23] = oci_execute($p1);
			
			$p2 =  oci_parse($conn, "UPDATE parents SET foffice ='".$foffice."' WHERE studentno = '".$snum."'" );
			$check[24] = oci_execute($p2);
			
			$p3 =  oci_parse($conn, "UPDATE parents SET fincome='".$fincome."' WHERE studentno = '".$snum."'" );
			$check[25] = oci_execute($p3);
			
			$p4 =  oci_parse($conn, "UPDATE parents SET flife ='".$flife."' WHERE studentno = '".$snum."'" );
			$check[26] = oci_execute($p4);
			
			$p5 =  oci_parse($conn, "UPDATE parents SET femployer ='".$femployer."' WHERE studentno = '".$snum."'" );
			$check[27] = oci_execute($p5);
			
			$p6 =  oci_parse($conn, "UPDATE parents SET ftelnum ='".$ftelnum."' WHERE studentno = '".$snum."'" );
			$check[28] = oci_execute($p6);
			
			$p7 =  oci_parse($conn, "UPDATE parents SET mothername ='".$mothername."' WHERE studentno = '".$snum."'" );
			$check[29] = oci_execute($p7);
			
			$p8 =  oci_parse($conn, "UPDATE parents SET mjob ='".$mjob."' WHERE studentno = '".$snum."'" );
			$check[30] = oci_execute($p8);
			
			$p9 =  oci_parse($conn, "UPDATE parents SET moffice ='".$moffice."' WHERE studentno = '".$snum."'" );
			$check[31] = oci_execute($p9);
			
			$p10 =  oci_parse($conn, "UPDATE parents SET mincome='".$mincome."' WHERE studentno = '".$snum."'" );
			$check[32] = oci_execute($p10);
			
			$p11 =  oci_parse($conn, "UPDATE parents SET mlife ='".$mlife."' WHERE studentno = '".$snum."'" );
			$check[33] = oci_execute($p11);
			
			$p12 =  oci_parse($conn, "UPDATE parents SET memployer ='".$memployer."' WHERE studentno = '".$snum."'" );
			$check[34] = oci_execute($p12);
			
			$p13 =  oci_parse($conn, "UPDATE parents SET mtelnum ='".$mtelnum."' WHERE studentno = '".$snum."'" );
			$check[35] = oci_execute($p13);
			
			$f =  oci_parse($conn, "UPDATE family SET region ='".$region."' WHERE studentno = '".$snum."'" );
			$check[36] = oci_execute($f);
			
			$f1 =  oci_parse($conn, "UPDATE family SET parentmarriagestatus ='".$parentStatus."' WHERE studentno = '".$snum."'" );
			$check[37] = oci_execute($f1);
			
			$f2 =  oci_parse($conn, "UPDATE family SET numbrothers ='".$numbro."' WHERE studentno = '".$snum."'" );
			$check[38] = oci_execute($f2);
			
			$f3 =  oci_parse($conn, "UPDATE family SET numsisters ='".$numsis."' WHERE studentno = '".$snum."'" );
			$check[39] = oci_execute($f3);
			
			$f4 =  oci_parse($conn, "UPDATE family SET orderbirth ='".$order."' WHERE studentno = '".$snum."'" );
			$check[40] = oci_execute($f4);
			
			$g =  oci_parse($conn, "UPDATE guardian SET name ='".$gname."' WHERE studentno = '".$snum."'" );
			$check[41] = oci_execute($g);
			
			$g1 =  oci_parse($conn, "UPDATE guardian SET address ='".$gadd."' WHERE studentno = '".$snum."'" );
			$check[42] = oci_execute($g1);
			
			$g2 =  oci_parse($conn, "UPDATE guardian SET telno ='".$gnum."' WHERE studentno = '".$snum."'" );
			$check[43] = oci_execute($g2);
			
			$s22 =  oci_parse($conn, "UPDATE STUDENT SET college ='".$college."' WHERE studentno = '".$snum."'" );
			$check[44] = oci_execute($s22);
			
			for($i=0;$i<45;$i++){
				if($check[$i]==false){
					$flag = 0;
					break;
				}
			}
			if($flag!=0){
				return 1;
			}else{
				return 0;
			}
		
		}
		
		function updateCheckin($snum,$date,$term,$room,$fname,$mname,$lname){
			$conn = oci_connect("naiad", "1234", "localhost/XE");
			
			$s =  oci_parse($conn, "UPDATE check_in SET term ='".$term."' WHERE studentno = '".$snum."'" );
			$check[0] = oci_execute($s);
			
			$s1 =  oci_parse($conn, "UPDATE check_in SET date_in ='".$date."' WHERE studentno = '".$snum."'" );
			$check[1] = oci_execute($s1);
			
			$s2 =  oci_parse($conn, "UPDATE check_in SET roomno='".$room."' WHERE studentno = '".$snum."'" );
			$check[2] = oci_execute($s2);
			
			$s3 =  oci_parse($conn, "UPDATE check_in SET namefirst ='".$fname."' WHERE studentno = '".$snum."'" );
			$check[3] = oci_execute($s3);
			
			$s4 =  oci_parse($conn, "UPDATE check_in SET namemiddle ='".$mname."' WHERE studentno = '".$snum."'" );
			$check[4] = oci_execute($s4);
			
			$s5 =  oci_parse($conn, "UPDATE check_in SET namelast='".$lname."' WHERE studentno = '".$snum."'" );
			$check[5] = oci_execute($s5);
			
			
			$flag=1;
			
			for($i=0;$i<6;$i++){
				if($check[$i]==false){
					$flag = 0;
					break;
				}
			}
			if($flag!=0){
				return 1;
			}else{
				return 0;
			}
		
		}
		
		function updateReservation($snum,$ornum,$date,$amt,$term,$remarks,$kdate,$kamount,$kremarks){
			$conn = oci_connect("naiad", "1234", "localhost/XE");
			
			$s =  oci_parse($conn, "UPDATE reservation SET term ='".$term."' WHERE studentno = '".$snum."'" );
			$check[0] = oci_execute($s);
			
			$s2 =  oci_parse($conn, "UPDATE reservation SET ornum ='".$ornum."' WHERE studentno = '".$snum."'" );
			$check[1] = oci_execute($s2);
			
			$s3 =  oci_parse($conn, "UPDATE reservation SET datereserved ='".$date."' WHERE studentno = '".$snum."'" );
			$check[2] = oci_execute($s3);
			
			$s4 =  oci_parse($conn, "UPDATE reservation SET amount ='".$amt."' WHERE studentno = '".$snum."'" );
			$check[3] = oci_execute($s4);
			
			$s5 =  oci_parse($conn, "UPDATE reservation SET remarks ='".$remarks."' WHERE studentno = '".$snum."'" );
			$check[4] = oci_execute($s5);
			
			$s6 =  oci_parse($conn, "UPDATE keydeposit SET remarks ='".$kremarks."' WHERE studentno = '".$snum."'" );
			$check[5] = oci_execute($s6);
			
			$s7 =  oci_parse($conn, "UPDATE keydeposit SET datereceived ='".$kdate."' WHERE studentno = '".$snum."'" );
			$check[6] = oci_execute($s7);
			
			$s8 =  oci_parse($conn, "UPDATE keydeposit SET amount ='".$kamount."' WHERE studentno = '".$snum."'" );
			$check[7] = oci_execute($s8);
			
			
			$flag=1;
			
			for($i=0;$i<8;$i++){
				if($check[$i]==false){
					$flag = 0;
					break;
				}
			}
			if($flag!=0){
				return 1;
			}else{
				return 0;
			}
		
		}
		
		function updatePayment($snum,$pterm,$term,$pporno,$df,$af,$tf,$paydate,$remarks,$duration){
			$conn = oci_connect("naiad", "1234", "localhost/XE");
			
			/*$s =  oci_parse($conn, "UPDATE payment SET receiptno ='".$pporno."' WHERE studentno = '".$snum."'" );
			oci_execute($s);*/
			
			$s1 =  oci_parse($conn, "UPDATE payment SET term ='".$term."' WHERE studentno = '".$snum."'" );
			$check[0] = oci_execute($s1);
			
			$s2 =  oci_parse($conn, "UPDATE payment SET periodcovered ='".$pterm."' WHERE studentno = '".$snum."'" );
			$check[1] = oci_execute($s2);
			
			$s3 =  oci_parse($conn, "UPDATE payment SET dormfee ='".$df."' WHERE studentno = '".$snum."'" );
			$check[2] = oci_execute($s3);
			
			$s4 =  oci_parse($conn, "UPDATE payment SET appliancefee ='".$af."' WHERE studentno = '".$snum."'" );
			$check[3] = oci_execute($s4);
			
			$s5 =  oci_parse($conn, "UPDATE payment SET transfee ='".$tf."' WHERE studentno = '".$snum."'" );
			$check[4] = oci_execute($s5);
			
			$s6 =  oci_parse($conn, "UPDATE payment SET datepaid ='".$paydate."' WHERE studentno = '".$snum."'" );
			$check[5] = oci_execute($s6);
			
			$s7 =  oci_parse($conn, "UPDATE payment SET remarks ='".$remarks."' WHERE studentno = '".$snum."'" );
			$check[6] = oci_execute($s7);
			
			$s8 =  oci_parse($conn, "UPDATE payment SET duration ='".$duration."' WHERE studentno = '".$snum."'" );
			$check[7] = oci_execute($s8);
			
			$flag=1;
			
			for($i=0;$i<8;$i++){
				if($check[$i]==false){
					$flag = 0;
					break;
				}
			}
			if($flag!=0){
				return 1;
			}else{
				return 0;
			}
		}
		
		function updateViolation($snum,$vdate,$nature,$action,$rdate){
			
			$conn = oci_connect("naiad", "1234", "localhost/XE");
			
			$s =  oci_parse($conn, "UPDATE violation SET dateviolation ='".$vdate."' WHERE studentno = '".$snum."'" );
			$check[0] = oci_execute($s);
		
			$s1 =  oci_parse($conn, "UPDATE violation SET nature='".$nature."' WHERE studentno = '".$snum."'" );
			$check[1] = oci_execute($s1);
			
			$s2 =  oci_parse($conn, "UPDATE violation SET actiontaken ='".$action."' WHERE studentno = '".$snum."'" );
			$check[2] = oci_execute($s2);
			
			$s3 =  oci_parse($conn, "UPDATE violation SET datereported ='".$rdate."' WHERE studentno = '".$snum."'" );
			$check[3] = oci_execute($s3);
			
			$flag=1;
			
			for($i=0;$i<4;$i++){
				if($check[$i]==false){
					$flag = 0;
					break;
				}
			}
			if($flag!=0){
				return 1;
			}else{
				return 0;
			}
		}
		
		function updateAppliance($snum,$aptype,$term,$aporno,$apdate,$remarks){
			
			$conn = oci_connect("naiad", "1234", "localhost/XE");
			
			$s =  oci_parse($conn, "UPDATE appliance SET type ='".$aptype."' WHERE studentno = '".$snum."'" );
			$check[0] = oci_execute($s);
			
			$s =  oci_parse($conn, "UPDATE appliance SET term ='".$term."' WHERE studentno = '".$snum."'" );
			$check[1] = oci_execute($s);
			
			$s =  oci_parse($conn, "UPDATE appliance SET dateinstalled ='".$apdate."' WHERE studentno = '".$snum."'" );
			$check[2] = oci_execute($s);
		
			$s =  oci_parse($conn, "UPDATE appliance SET remarks ='".$remarks."' WHERE studentno = '".$snum."'" );
			$check[3] = oci_execute($s);
			
			$flag=1;
			
			for($i=0;$i<4;$i++){
				if($check[$i]==false){
					$flag = 0;
					break;
				}
			}
			if($flag!=0){
				return 1;
			}else{
				return 0;
			}
		}
		
		function showMessage($flag) {
				if($flag==1){
					$msg = "Successfully Updated!";
					$destination = "front.html";
				}else{
					$msg = "Error in updating!";
					$destination = "editResident.php";
				}
			
				echo("<html>\n");
				echo("<head>\n");
				echo("<title>System Message</title>\n");
				echo("<meta http-equiv=\"Content-Type\" content=\"text/html;
				charset=iso-8859-1\">\n");

				echo("<script language=\"JavaScript\" type=\"text/JavaScript\">\n");
				echo("alert('$msg');\n");
				echo("window.location = ('$destination');\n");
				echo("</script>\n");
				echo("</head>\n");
				echo("<body>\n");
				echo("</body>\n");
				echo("</html>\n");
				exit;
			}
	
	}



?>